home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************
- * TEXTRA AREXX script -- Mike Haas, 1991, All Rights Reserved. *
- * Freely distributable ONLY as a component of the TEXTRA package. *
- * This banner may not be removed or altered (improvements to the *
- * actual program welcome). Please document and send to me. *
- * !!! PLACE THIS FILE IN YOUR REXX: DIRECTORY !!! *
- ******************************************************************/
-
- /* Usage: Unparagraph
- *
- * Paragraph is a specialized formatting script. It operates on
- * the current SELECT range and, using blank lines as paragraph delimeters
- * (like paragraph.textra), truncates each paragraph into a single line.
- *
- * Thes file is then suitable for formatting with Textra's "margin"
- * mode. Activating the mode will format each paragraph and the
- * user may take it from there.
- *
- */
-
- OPTIONS results
-
- rex = 0; result = "NOTSUPPORTED" /*00002*/
- textraversion
- parse var result maj min rex
- if (result == "NOTSUPPORTED") | (rex < 12) then do
- notify "Textra V1.15 or later required for this script."
- exit
- end
-
-
- get select position
-
- if (result == "NO SELECT") then do /* is nothing selected? */
-
- ask "Unparagraph from cursor to end of file?"
- if (result ~= "YES") then do
- notify "Try selecting some text and trying again."
- exit
- end
- get cursor position
- parse var result startx' 'starty
- lastline
- selectto startx starty
- get select position
-
- end
-
- /* yes, there is a selection, get it's boundaries */
- parse var result startx ' ' starty ' ' endx ' ' endy
-
-
- currx = startx
- curry = starty
- nomore = 0
- bsto = -1
-
- /* temporarily make sure auto indent is off */
- prefs autoindent read; autoistate = result
- prefs autoindent off
-
- /* if nothing on the endline is actually selected, don't include it */
- if (endx == 0) then endy = endy - 1
-
- gotoxy 0 curry
- get cursor char
- do while ((result == " ") | (result == " ") /*TAB*/)
- del
- get cursor char
- end
-
- curry = curry+1
-
- do while ((curry <= endy) & (nomore == 0))
-
- CheckCancel; if (result == CANCEL) then exit /*00001*/
-
- lib = IsLineBlank(curry)
- if (lib = NO) then do
-
- /* we need to concat with the one above */
- gotoxy 0 curry
- get cursor char
- do while ((result == " ") | (result == " ") /*TAB*/)
- del
- get cursor char
- end
- gotoxy 0 curry-1
- column "-1"
- left 1
- get cursor char
- parse var result echar
- right 1
- if (echar ~= ' ') & (echar ~= ' '/*TAB*/) then
- text '" "'
- del
- endy = endy - 1
- end
-
- else do
-
- /* line is blank, find next non blank */
-
- blfound = YES
- do while ((curry <= endy) & (nomore == 0) & (blfound = YES))
- curry = curry + 1
- blfound = IsLineBlank(curry)
- end
- if (blfound = NO) then do
- gotoxy 0 curry
- get cursor char
- do while ((result == " ") | (result == " ") /*TAB*/)
- del
- get cursor char
- end
- curry = curry + 1
- end
- end
-
- end
-
- /* restore autoindent */
- prefs autoindent autoistate
-
-
- exit
-
-
-
- IsLineBlank:
- parse arg linen
- ifBlank = "NO"
- /*
- get line linen
- parse var result linetext
- cmpres = compare(' ',linetext,' ')
- if cmpres = 0 then
- ifBlank = "YES"
- */
-
- gotoxy 0 curry
- get cursor char
- do while ((result == " ") | (result == " ") /*TAB*/)
- right 1
- get cursor char
- end
- if result = "-1" then
- ifBlank = 1
-
- return ifBlank
-